<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>WeChat Public Account Demo</title>
</head>
<body>

<button id="openPublicAccountBtn">Open WeChat Public Account</button>

<script src="https://res.wx.qq.com/open/js/jweixin-1.6.0.js"></script>
<script>
    document.querySelector('#openPublicAccountBtn').addEventListener('click', function() {
        // Replace 'your_public_account_id' with the actual original ID of your target public account
        var publicAccountId = 'gh_671ee133c795';

        // Construct the WeChat URL scheme to open the public account directly
        var wechatUrl = 'weixin://profile/' + publicAccountId;

        // Check if the WeChat app is installed
        setTimeout(function (){
            if (typeof WeixinJSBridge !== 'undefined') {
                // Open the WeChat app with the constructed URL
                WeixinJSBridge.invoke('openUrl', {
                    url: wechatUrl
                }, function(res) {
                    // Handle the result if needed
                    console.log(res);
                });
            } else {
                // If WeixinJSBridge is not available, fallback to a standard URL redirection
                window.location.href = wechatUrl;
            }
        }, 200)

    });
</script>

</body>
</html>
